package com.example;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class TradeStats implements Serializable {
    private static final long serialVersionUID = 1L;

    private Long totalAmount;
    private Long buyVolume;
    private Long sellVolume;
    private Map<String, Long> platformVolumes;
    private Map<String, Long> stockAmounts;
    private Map<String, Long> geographicDistribution;

    // 初始化方法
    public void initialize() {
        totalAmount = 0L;
        buyVolume = 0L;
        sellVolume = 0L;
        platformVolumes = new HashMap<>();
        stockAmounts = new HashMap<>();
        geographicDistribution = new HashMap<>();
    }

    // 用于深拷贝的方法
    public TradeStats copy() {
        TradeStats copy = new TradeStats();
        copy.setTotalAmount(this.totalAmount);
        copy.setBuyVolume(this.buyVolume);
        copy.setSellVolume(this.sellVolume);
        copy.setPlatformVolumes(new HashMap<>(this.platformVolumes));
        copy.setStockAmounts(new HashMap<>(this.stockAmounts));
        copy.setGeographicDistribution(new HashMap<>(this.geographicDistribution));
        return copy;
    }

    @Override
    public String toString() {
        return "TradeStats{" +
                "totalAmount=" + totalAmount +
                ", buyVolume=" + buyVolume +
                ", sellVolume=" + sellVolume +
                ", platformVolumes=" + platformVolumes +
                ", stockAmounts=" + stockAmounts +
                ", geographicDistribution=" + geographicDistribution +
                '}';
    }
}